#include "../include/algebraicExpression.hpp"
#include "../include/term.hpp"
#include "../include/variable.hpp"
#include "../include/q.hpp"
#include <iostream>
#include <string>
#include <vector>

using namespace mt;
using namespace std;

int main(int argc, char** argv) {
  typedef Q<int> t_int;
  AlgebraicExpression<t_int> x1;
  AlgebraicExpression<t_int> x2;
  AlgebraicExpression<t_int> x3;
  Variable<t_int> a("x",2);
  Variable<t_int> b("x",1);
  Term<t_int> y1(1,a);
  Term<t_int> y2(2,b);
  Term<t_int> y3(1);
  vector<Term<t_int> > x;
  x.push_back(y1);
  x.push_back(y2);
  x.push_back(y3);
  x1 = x;
  vector<Term<t_int> > z1;
  z1 = x1.getAE();
  Term<t_int> m;
  Q<int> zero = 0;
  for (int i =0; i<z1.size();i++) {
    m= z1[i];
    if (i>0) {
      if (m.getCoefficient() > zero) cout << " + " << m.getCoefficient();
//      else cout << " - " << (m.getCoefficient() * -1);
    }
    else cout << (m.getCoefficient());
    std::vector<Variable<t_int> > b = m.getVariable();
    Variable<t_int> temp1;
    for (int i=0; i < b.size(); i++) {
      temp1 = b[i];
      cout << temp1.getName() << "^" << temp1.getExponent();
    }

  }
  cout << endl;

  vector<Term<t_int> > x10;
  x10.push_back(y1);
  x10.push_back(y3);
  x2 = x10;
  x3 = x1 - x2;
  z1 = x3.getAE();
  Term<t_int> m0;
  Q<int> zero0 = 0;
  for (int i =0; i<z1.size();i++) {
    m0= z1[i];
    if (i>0) {
      if (m0.getCoefficient() > zero0) cout << " + " << m0.getCoefficient();
//      else cout << " - " << (m.getCoefficient() * -1);
    }
    else cout << (m0.getCoefficient());
    std::vector<Variable<t_int> > b0 = m0.getVariable();
    Variable<t_int> temp10;
    for (int i=0; i < b0.size(); i++) {
      temp10 = b0[i];
      cout << temp10.getName() << "^" << temp10.getExponent();
    }

  }
  cout << endl;



  return 0;

}
